<?php
namespace app\index\model;

use think\Model;

class JokeArticle extends Model
{
	protected $pk = 'joke_id';
	protected $table = 'joke_article';

	//自定义初始化
    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        //TODO:自定义的初始化
    }

    //自定义初始化
    protected static function init2()
    {
        //TODO:自定义的初始化
    }

    public static function toArr($obj)
    {
    	$array = array();
    	foreach ($obj as $key => $value) {
    		$array [$key]= (object) $value->data;
    	}
    	return $array;
    }

    public static function findAll($where = null, $column = '*', $limit = 10)
    {
    	$all = self::field($column)->where($where)->order(['joke_id' => 'desc'])->limit($limit)->select();
    	return self::toArr($all);
    }
}
